import React from 'react';
import { Popover as AntdPopover } from 'antd';
import type { PopoverProps as AntdPopoverProps } from 'antd';
import { createStyles } from 'antd-style';

export interface PopoverProps extends AntdPopoverProps {
  /**
   * @description 自定义样式类名
   */
  customClassName?: string;
}

const useStyles = createStyles(({ token, css }) => ({
  popover: css`
    z-index: ${token.zIndexPopupBase};
  `,
}));

const PopoverComponent: React.FC<PopoverProps> = ({ customClassName, className, ...restProps }) => {
  const { styles, cx } = useStyles();
  
  const popoverClassName = cx(
    className,
    customClassName,
    styles.popover
  );

  return <AntdPopover className={popoverClassName} {...restProps} />;
};

const Popover = Object.assign(PopoverComponent, {
  _InternalPanelDoNotUseOrYouWillBeFired: (AntdPopover as any)._InternalPanelDoNotUseOrYouWillBeFired,
});

export { Popover };
export default Popover;

